//
//  HMmyLoveTableView.m
//  G05爱鲜蜂
//
//  Created by 小灰灰 on 16/10/16.
//  Copyright © 2016年 何源. All rights reserved.
//

#import "HMmyLoveTableView.h"
#import "HMmyLoveTableViewCell.h"
static NSString *ideID = @"HMmyLoveTableView";
@interface HMmyLoveTableView()<UITableViewDelegate,UITableViewDataSource>

@end
@implementation HMmyLoveTableView
-(instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
    
   self = [super initWithFrame:frame style:style];
    
  if(self)
  {
//      HMmyLoveTableViewCell *cell = [HMmyLoveTableViewCell loadMyLoveTableViewCell];
//      [self addSubview:cell];
      self.delegate = self;
      self.dataSource = self;
//      [self registerClass:[HMmyLoveTableViewCell class] forCellReuseIdentifier:ideID];
      self.sectionHeaderHeight = 10;
  }
    return self;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if(section == 0){
        return 2;
    }
    else if (section == 1){
        return 1;
    }
    return 2;
}
-(UITableViewCell *)tableView:(UITableView *)tableView
        cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    //这句话解决点击缓慢
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    HMmyLoveTableViewCell *cell = [HMmyLoveTableViewCell loadMyLoveTableViewCell];
    if(indexPath.section == 0 && indexPath.row == 1)
    {
        [cell setAdressImage:@"icon_mystore" andContentLabel:@"我的店铺"];
    }
    else if(indexPath.section == 1 && indexPath.row == 0){
        
        [cell setAdressImage:@"v2_my_share_icon" andContentLabel:@"把爱鲜蜂分享给好友"];
    }
    else if(indexPath.section == 2 && indexPath.row == 0){
        [cell setAdressImage:@"online_service" andContentLabel:@"客服帮助"];
    }
    else if(indexPath.section == 2 && indexPath.row == 1){
        [cell setAdressImage:@"v2_my_feedback_icon" andContentLabel:@"意见反馈"];
    }
        return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 1;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.section == 0 && indexPath.row == 0)
    {
        
        if(self.jumpToBlock){
            self.jumpToBlock(JumpToVCGetGoods);
        }
    }
    else if(indexPath.section == 0 && indexPath.row == 1){
        
        if(self.jumpToBlock){
            self.jumpToBlock(JumpToVCMyShop);
        }
        
    }
    
    else if(indexPath.section == 1 && indexPath.row == 0){
        if(self.jumpToBlock){
            self.jumpToBlock(JumpToVCShare);
        }
        
    }
    else if(indexPath.section == 2 && indexPath.row == 0){
        if(self.jumpToBlock){
            self.jumpToBlock(JumpToVCHelp);
        }
        
    }
    else if(indexPath.section == 2 && indexPath.row == 1){
        if(self.jumpToBlock){
            self.jumpToBlock(JumpToVCAdvice);
        }
        
    }
    
}
@end
